package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.ScenicDetail;
import cn.wolfcode.wolf2w.repository.ScenicDetailMongoRepository;
import cn.wolfcode.wolf2w.service.IScenicDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScenicDetailServiceImpl implements IScenicDetailService {

    @Autowired
    private ScenicDetailMongoRepository repository;
    @Autowired
    private MongoTemplate template;

    @Override
    public void save(ScenicDetail scenicDetail) {
        scenicDetail.setId(null);
        repository.save(scenicDetail);
    }

    @Override
    public void delete(String id) {
        repository.deleteById(id);
    }

    @Override
    public void update(ScenicDetail scenicDetail) {
        repository.save(scenicDetail);
    }

    @Override
    public ScenicDetail find(String id) {
        ScenicDetail scenicDetail = repository.findById(id).orElse(null);

        return scenicDetail;
    }

    @Override
    public List<ScenicDetail> findAll() {
        List<ScenicDetail> list = repository.findAll();
        return list;
    }
}
